package com.youran.restful.webprinter.ctrl;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.youran.restful.webprinter.util.Generator;

public class CommonCtrl {

	private Logger logger = LoggerFactory.getLogger(CommonCtrl.class);

	/**
	 * 通过PathVariable获取动态参数
	 * @param id 动态参数
	 * @param model 参数集合
	 * @return
	 */
//	@RequestMapping(value = "/clear/{id}", method = RequestMethod.GET)
//	public String clear(@PathVariable String id, Model model) {
//		
//	}
	
	protected String getDefaultStorePath() {
		return getStorePath(getGenId());
	}
	
	protected String getGenId() {
		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
		return Generator.generatId(request);
	}
	
	protected String getStorePath(String genId) {
		return (getRootPath() + genId + "/");
	}
	
	protected String getRootPath() {
		return "data/";
	}
}
